package db;


import java.sql.Connection;
import java.util.ResourceBundle;



public abstract class DBConnectionFactory {
	
	private static String driverName="";
    private static String url="";
    private static String username="";
    private static String password="";
    private static int typeOfFactory=0;
    private final static int MYSQL = 1;
    
    public static DBConnectionFactory getInstance(){
        ResourceBundle rb = ResourceBundle.getBundle("database");
 
        driverName = rb.getString("driverName");
        url=rb.getString("url");
        username=rb.getString("username");
        password=rb.getString("password");
        typeOfFactory=Integer.parseInt(rb.getString("typeOfFactory"));
        
        switch (typeOfFactory){
            case MYSQL: return new SqlFactory();
        }
        return new SqlFactory();
    }
    
    public abstract Connection getConnection();

    public String getDriverName() {
        return driverName;
    }

    public String getUrl() {
        return url;
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }
}
